\hypertarget{classBinarySearchTree}{}\doxysection{Binary\+Search\+Tree$<$ Comparable $>$ Class Template Reference}
\label{classBinarySearchTree}\index{BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}}


Binary\+Search\+Tree的\+Comparable模板类;.  




{\ttfamily \#include $<$Binary\+Search\+Tree.\+h$>$}

\doxysubsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{classBinarySearchTree_a93b575b9a03bae5a402f69a1a3b96d8f}\label{classBinarySearchTree_a93b575b9a03bae5a402f69a1a3b96d8f}} 
\mbox{\hyperlink{classBinarySearchTree_a93b575b9a03bae5a402f69a1a3b96d8f}{Binary\+Search\+Tree}} ()
\begin{DoxyCompactList}\small\item\em 默认\+Binary\+Search\+Tree构造函数; \end{DoxyCompactList}\item 
\mbox{\hyperlink{classBinarySearchTree_a399127538d6b6e1581396cafa5d3aa6e}{Binary\+Search\+Tree}} (const \mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}} \&rhs)
\begin{DoxyCompactList}\small\item\em 有左值传入的\+Binary\+Search\+Tree构造函数; \end{DoxyCompactList}\item 
\mbox{\hyperlink{classBinarySearchTree_af5a89639e88a69c7c8ed757e9a910fdf}{Binary\+Search\+Tree}} (\mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}} \&\&rhs)
\begin{DoxyCompactList}\small\item\em 有右值传入的\+Binary\+Search\+Tree构造函数; \end{DoxyCompactList}\item 
\mbox{\Hypertarget{classBinarySearchTree_a32b5d201d1882fed79be9e0db0a65efc}\label{classBinarySearchTree_a32b5d201d1882fed79be9e0db0a65efc}} 
\mbox{\hyperlink{classBinarySearchTree_a32b5d201d1882fed79be9e0db0a65efc}{$\sim$\+Binary\+Search\+Tree}} ()
\begin{DoxyCompactList}\small\item\em 默认\+Binary\+Search\+Tree析构函数; \end{DoxyCompactList}\item 
\mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}} \& \mbox{\hyperlink{classBinarySearchTree_a28066217f90c86d362b8db2a00f5c6b1}{operator=}} (const \mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}} \&rhs)
\begin{DoxyCompactList}\small\item\em 重载=号(赋值)，同时避免了更改rhs的地址; \end{DoxyCompactList}\item 
\mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}} \& \mbox{\hyperlink{classBinarySearchTree_ab8c5df2c527a9aff70a5addae99cab2f}{operator=}} (\mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}} \&\&rhs)
\begin{DoxyCompactList}\small\item\em 重载=号(赋值)，swap函数直接交换地址，因为右值对象马上会被释放; \end{DoxyCompactList}\item 
const Comparable \& \mbox{\hyperlink{classBinarySearchTree_a27264b8257042bced77b5a3ed554aca5}{find\+Min}} () const
\begin{DoxyCompactList}\small\item\em 找\+Binary\+Search\+Tree类中存储的最小的元素; \end{DoxyCompactList}\item 
const Comparable \& \mbox{\hyperlink{classBinarySearchTree_a23eff12a71929966684d056b7ddc89dd}{find\+Max}} () const
\begin{DoxyCompactList}\small\item\em 找\+Binary\+Search\+Tree类中存储的最小的元素; \end{DoxyCompactList}\item 
bool \mbox{\hyperlink{classBinarySearchTree_a1a234431661b762fd4df77c5c6d0b3b1}{contains}} (const Comparable \&x) const
\begin{DoxyCompactList}\small\item\em 判断x元素是否在\+Binary\+Search\+Tree中; \end{DoxyCompactList}\item 
bool \mbox{\hyperlink{classBinarySearchTree_a6b2d9cdc6a90f6dd9cfe753958d5ce1d}{is\+Empty}} () const
\begin{DoxyCompactList}\small\item\em 判断\+Binary\+Search\+Tree是否为空树; \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classBinarySearchTree_a8ddd2becc339171650a6fe9ed6481b49}{print\+Tree}} (ostream \&out=cout) const
\begin{DoxyCompactList}\small\item\em 通过调用私有类中的print\+List函数，用中序遍历将\+Binary\+Search\+Tree树中元素打印出来; \end{DoxyCompactList}\item 
\mbox{\Hypertarget{classBinarySearchTree_a1e79b79da19f7cd0a7bc854f746bae7c}\label{classBinarySearchTree_a1e79b79da19f7cd0a7bc854f746bae7c}} 
void \mbox{\hyperlink{classBinarySearchTree_a1e79b79da19f7cd0a7bc854f746bae7c}{make\+Empty}} ()
\begin{DoxyCompactList}\small\item\em 通过调用私有类中的make\+Empty函数清空\+Binary\+Search\+Tree; \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classBinarySearchTree_a3747b26226a3205295b9b56d51eba9e6}{insert}} (const Comparable \&x)
\begin{DoxyCompactList}\small\item\em 通过调用私有类中的insert函数将传入的\+Comparable对象的左值引用x插入到\+Binary\+Search\+Tree中; \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classBinarySearchTree_a00c741c480cf0fc2ffd478e66aa5eb55}{insert}} (Comparable \&\&x)
\begin{DoxyCompactList}\small\item\em 通过调用私有类中的insert函数将传入的\+Comparable对象的右值引用x插入到\+Binary\+Search\+Tree中; \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classBinarySearchTree_a27118a2c01d39ccaa07d55a3507d4f24}{remove}} (const Comparable \&x)
\begin{DoxyCompactList}\small\item\em 通过调用私有类中的remove函数将传入的\+Comparable对象的引用x从\+Binary\+Search\+Tree中移除; \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classBinarySearchTree_a6dfb13e00236626dd2ae3a8ccad335a5}{add}} (std\+::vector$<$ Comparable $>$ \&arr) const
\begin{DoxyCompactList}\small\item\em 通过调用私有类中的add函数将排好序后的元素返回到arr所引用的数组对象; \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
\subsubsection*{template$<$typename Comparable$>$\newline
class Binary\+Search\+Tree$<$ Comparable $>$}

Binary\+Search\+Tree的\+Comparable模板类;. 


\begin{DoxyTemplParams}{Template Parameters}
{\em Comparable} & Binary\+Search\+Tree的类型; \\
\hline
\end{DoxyTemplParams}


\doxysubsection{Constructor \& Destructor Documentation}
\mbox{\Hypertarget{classBinarySearchTree_a399127538d6b6e1581396cafa5d3aa6e}\label{classBinarySearchTree_a399127538d6b6e1581396cafa5d3aa6e}} 
\index{BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}!BinarySearchTree@{BinarySearchTree}}
\index{BinarySearchTree@{BinarySearchTree}!BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}}
\doxysubsubsection{\texorpdfstring{BinarySearchTree()}{BinarySearchTree()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily template$<$typename Comparable $>$ \\
\mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}}$<$ Comparable $>$\+::\mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}} (\begin{DoxyParamCaption}\item[{const \mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}}$<$ Comparable $>$ \&}]{rhs }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



有左值传入的\+Binary\+Search\+Tree构造函数; 


\begin{DoxyParams}{Parameters}
{\em rhs} & 传入的\+Binary\+Search\+Tree左值引用rhs; \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{classBinarySearchTree_af5a89639e88a69c7c8ed757e9a910fdf}\label{classBinarySearchTree_af5a89639e88a69c7c8ed757e9a910fdf}} 
\index{BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}!BinarySearchTree@{BinarySearchTree}}
\index{BinarySearchTree@{BinarySearchTree}!BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}}
\doxysubsubsection{\texorpdfstring{BinarySearchTree()}{BinarySearchTree()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily template$<$typename Comparable $>$ \\
\mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}}$<$ Comparable $>$\+::\mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}} (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}}$<$ Comparable $>$ \&\&}]{rhs }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



有右值传入的\+Binary\+Search\+Tree构造函数; 


\begin{DoxyParams}{Parameters}
{\em rhs} & 传入的\+Binary\+Search\+Tree右值引用rhs; \\
\hline
\end{DoxyParams}


\doxysubsection{Member Function Documentation}
\mbox{\Hypertarget{classBinarySearchTree_a6dfb13e00236626dd2ae3a8ccad335a5}\label{classBinarySearchTree_a6dfb13e00236626dd2ae3a8ccad335a5}} 
\index{BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}!add@{add}}
\index{add@{add}!BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}}
\doxysubsubsection{\texorpdfstring{add()}{add()}}
{\footnotesize\ttfamily template$<$typename Comparable $>$ \\
void \mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}}$<$ Comparable $>$\+::add (\begin{DoxyParamCaption}\item[{std\+::vector$<$ Comparable $>$ \&}]{arr }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



通过调用私有类中的add函数将排好序后的元素返回到arr所引用的数组对象; 


\begin{DoxyParams}{Parameters}
{\em arr} & 将数据返回到的数组对象arr的引用; \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{classBinarySearchTree_a1a234431661b762fd4df77c5c6d0b3b1}\label{classBinarySearchTree_a1a234431661b762fd4df77c5c6d0b3b1}} 
\index{BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}!contains@{contains}}
\index{contains@{contains}!BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}}
\doxysubsubsection{\texorpdfstring{contains()}{contains()}}
{\footnotesize\ttfamily template$<$typename Comparable $>$ \\
bool \mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}}$<$ Comparable $>$\+::contains (\begin{DoxyParamCaption}\item[{const Comparable \&}]{x }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



判断x元素是否在\+Binary\+Search\+Tree中; 


\begin{DoxyParams}{Parameters}
{\em x} & 传入的\+Comparable类型对象的const引用; \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
通过调用私有类中contains函数，若x元素存在则返回true;否则返回false; 
\end{DoxyReturn}
\mbox{\Hypertarget{classBinarySearchTree_a23eff12a71929966684d056b7ddc89dd}\label{classBinarySearchTree_a23eff12a71929966684d056b7ddc89dd}} 
\index{BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}!findMax@{findMax}}
\index{findMax@{findMax}!BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}}
\doxysubsubsection{\texorpdfstring{findMax()}{findMax()}}
{\footnotesize\ttfamily template$<$typename Comparable $>$ \\
const Comparable\& \mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}}$<$ Comparable $>$\+::find\+Max (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



找\+Binary\+Search\+Tree类中存储的最小的元素; 

\begin{DoxyReturn}{Returns}
若树是空的，直接报错，否则通过调用私有类中find\+Max函数返回$\ast$\+Binary\+Search\+Node-\/$>$element，即指针指向的最大元素; 
\end{DoxyReturn}
\mbox{\Hypertarget{classBinarySearchTree_a27264b8257042bced77b5a3ed554aca5}\label{classBinarySearchTree_a27264b8257042bced77b5a3ed554aca5}} 
\index{BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}!findMin@{findMin}}
\index{findMin@{findMin}!BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}}
\doxysubsubsection{\texorpdfstring{findMin()}{findMin()}}
{\footnotesize\ttfamily template$<$typename Comparable $>$ \\
const Comparable\& \mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}}$<$ Comparable $>$\+::find\+Min (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



找\+Binary\+Search\+Tree类中存储的最小的元素; 

\begin{DoxyReturn}{Returns}
若树是空的，直接报错，否则通过调用私有类中find\+Min函数返回$\ast$\+Binary\+Search\+Node-\/$>$element，即指针指向的最小元素; 
\end{DoxyReturn}
\mbox{\Hypertarget{classBinarySearchTree_a00c741c480cf0fc2ffd478e66aa5eb55}\label{classBinarySearchTree_a00c741c480cf0fc2ffd478e66aa5eb55}} 
\index{BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}!insert@{insert}}
\index{insert@{insert}!BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}}
\doxysubsubsection{\texorpdfstring{insert()}{insert()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily template$<$typename Comparable $>$ \\
void \mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}}$<$ Comparable $>$\+::insert (\begin{DoxyParamCaption}\item[{Comparable \&\&}]{x }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



通过调用私有类中的insert函数将传入的\+Comparable对象的右值引用x插入到\+Binary\+Search\+Tree中; 


\begin{DoxyParams}{Parameters}
{\em x} & 传入的\+Comparable对象的const右值引用x; \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{classBinarySearchTree_a3747b26226a3205295b9b56d51eba9e6}\label{classBinarySearchTree_a3747b26226a3205295b9b56d51eba9e6}} 
\index{BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}!insert@{insert}}
\index{insert@{insert}!BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}}
\doxysubsubsection{\texorpdfstring{insert()}{insert()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily template$<$typename Comparable $>$ \\
void \mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}}$<$ Comparable $>$\+::insert (\begin{DoxyParamCaption}\item[{const Comparable \&}]{x }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



通过调用私有类中的insert函数将传入的\+Comparable对象的左值引用x插入到\+Binary\+Search\+Tree中; 


\begin{DoxyParams}{Parameters}
{\em x} & 传入的\+Comparable对象的const左值引用x; \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{classBinarySearchTree_a6b2d9cdc6a90f6dd9cfe753958d5ce1d}\label{classBinarySearchTree_a6b2d9cdc6a90f6dd9cfe753958d5ce1d}} 
\index{BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}!isEmpty@{isEmpty}}
\index{isEmpty@{isEmpty}!BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}}
\doxysubsubsection{\texorpdfstring{isEmpty()}{isEmpty()}}
{\footnotesize\ttfamily template$<$typename Comparable $>$ \\
bool \mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}}$<$ Comparable $>$\+::is\+Empty (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



判断\+Binary\+Search\+Tree是否为空树; 

\begin{DoxyReturn}{Returns}
若树非空，返回false，反之返回true; 
\end{DoxyReturn}
\mbox{\Hypertarget{classBinarySearchTree_ab8c5df2c527a9aff70a5addae99cab2f}\label{classBinarySearchTree_ab8c5df2c527a9aff70a5addae99cab2f}} 
\index{BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}!operator=@{operator=}}
\index{operator=@{operator=}!BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}}
\doxysubsubsection{\texorpdfstring{operator=()}{operator=()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily template$<$typename Comparable $>$ \\
\mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}}\& \mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}}$<$ Comparable $>$\+::operator= (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}}$<$ Comparable $>$ \&\&}]{rhs }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



重载=号(赋值)，swap函数直接交换地址，因为右值对象马上会被释放; 


\begin{DoxyParams}{Parameters}
{\em rhs} & const引用符号右侧的\+Binary\+Search\+Tree类右值对象; \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
指针this指向的\+Binary\+Search\+Tree对象; 
\end{DoxyReturn}
\mbox{\Hypertarget{classBinarySearchTree_a28066217f90c86d362b8db2a00f5c6b1}\label{classBinarySearchTree_a28066217f90c86d362b8db2a00f5c6b1}} 
\index{BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}!operator=@{operator=}}
\index{operator=@{operator=}!BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}}
\doxysubsubsection{\texorpdfstring{operator=()}{operator=()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily template$<$typename Comparable $>$ \\
\mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}}\& \mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}}$<$ Comparable $>$\+::operator= (\begin{DoxyParamCaption}\item[{const \mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}}$<$ Comparable $>$ \&}]{rhs }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



重载=号(赋值)，同时避免了更改rhs的地址; 


\begin{DoxyParams}{Parameters}
{\em rhs} & const引用符号右侧的\+Binary\+Search\+Tree类左值对象; \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
指针this指向的\+Binary\+Search\+Tree对象; 
\end{DoxyReturn}
\mbox{\Hypertarget{classBinarySearchTree_a8ddd2becc339171650a6fe9ed6481b49}\label{classBinarySearchTree_a8ddd2becc339171650a6fe9ed6481b49}} 
\index{BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}!printTree@{printTree}}
\index{printTree@{printTree}!BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}}
\doxysubsubsection{\texorpdfstring{printTree()}{printTree()}}
{\footnotesize\ttfamily template$<$typename Comparable $>$ \\
void \mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}}$<$ Comparable $>$\+::print\+Tree (\begin{DoxyParamCaption}\item[{ostream \&}]{out = {\ttfamily cout} }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



通过调用私有类中的print\+List函数，用中序遍历将\+Binary\+Search\+Tree树中元素打印出来; 


\begin{DoxyParams}{Parameters}
{\em out} & ostream类对象的一个引用，默认是cout的引用; \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{classBinarySearchTree_a27118a2c01d39ccaa07d55a3507d4f24}\label{classBinarySearchTree_a27118a2c01d39ccaa07d55a3507d4f24}} 
\index{BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}!remove@{remove}}
\index{remove@{remove}!BinarySearchTree$<$ Comparable $>$@{BinarySearchTree$<$ Comparable $>$}}
\doxysubsubsection{\texorpdfstring{remove()}{remove()}}
{\footnotesize\ttfamily template$<$typename Comparable $>$ \\
void \mbox{\hyperlink{classBinarySearchTree}{Binary\+Search\+Tree}}$<$ Comparable $>$\+::remove (\begin{DoxyParamCaption}\item[{const Comparable \&}]{x }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



通过调用私有类中的remove函数将传入的\+Comparable对象的引用x从\+Binary\+Search\+Tree中移除; 


\begin{DoxyParams}{Parameters}
{\em x} & 传入的\+Comparable对象的const引用x; \\
\hline
\end{DoxyParams}


The documentation for this class was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
Binary\+Search\+Tree.\+h\end{DoxyCompactItemize}
